Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fallback option UseCurrentReplicasAsMinimum #6464

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

rickbrouwer
Copy link
Contributor

@rickbrouwer rickbrouwer commented Jan 5, 2025

When you are running a large number of pods and something goes wrong, Keda uses a fallback (if configured). However, the difference between the fallback.replicas and the current number of replicas can be large.
"Something going wrong" can also be temporary, which means it can suddenly scale down considerably and then return to the correct number of replicas.
With this PR, I want to make sure that you can indicate that it should use the current number of replicas (useCurrentReplicasAsMinimum) as fallback. If the given fallback.replicas is higher than the current replicas, then the fallback.replicas will be used.

  • A new parameter has been added to the fallback struct (behavior) with two options static (default) and useCurrentReplicasAsMinimum.
  • An adjustment has been made in the fallback.go to retrieve the current number of replicas
  • In the scale_scaledobjects.go there was code that determined what the current number of replicas was. This has been moved to the scale_resolvers.go
  • Fallback modified to determine whether to fall back to the fallback.replicas or the current number of replicas

If for any reason this option is not desired, please let me know.

Checklist

Fixes #6450
Docs: kedacore/keda-docs#1519
Relates to discussion: #6334

@rickbrouwer rickbrouwer requested a review from a team as a code owner January 5, 2025 17:50
@rickbrouwer rickbrouwer marked this pull request as draft January 5, 2025 17:50
Signed-off-by: Rick Brouwer <[email protected]>
Signed-off-by: Rick Brouwer <[email protected]>
Signed-off-by: Rick Brouwer <[email protected]>
@rickbrouwer rickbrouwer marked this pull request as ready for review January 6, 2025 09:17
Copy link
Member

@wozniakjan wozniakjan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, I like this a lot!

pkg/fallback/fallback.go Outdated Show resolved Hide resolved
apis/keda/v1alpha1/scaledobject_types.go Outdated Show resolved Hide resolved
@rickbrouwer rickbrouwer marked this pull request as draft January 15, 2025 16:31
@rickbrouwer rickbrouwer force-pushed the fallback branch 3 times, most recently from caa059c to 34abee5 Compare January 15, 2025 18:03
@rickbrouwer rickbrouwer marked this pull request as ready for review January 15, 2025 18:04
@rickbrouwer rickbrouwer changed the title Use CurrentReplicas as a minimum for fallback replicas Add Fallback option UseCurrentReplicasAsMinimum Jan 16, 2025
Signed-off-by: rickbrouwer <[email protected]>
Copy link
Member

@wozniakjan wozniakjan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a minor suggestion for simplification, I think semantically this should be equivalent, just less code to maintain :)

Let me know if you find any discrepancies

apis/keda/v1alpha1/scaledobject_types.go Outdated Show resolved Hide resolved
apis/keda/v1alpha1/scaledobject_types.go Outdated Show resolved Hide resolved
rickbrouwer and others added 3 commits January 17, 2025 15:47
Co-authored-by: Jan Wozniak <[email protected]>
Signed-off-by: rickbrouwer <[email protected]>
Co-authored-by: Jan Wozniak <[email protected]>
Signed-off-by: rickbrouwer <[email protected]>
Signed-off-by: Rick Brouwer <[email protected]>
@JorTurFer
Copy link
Member

Sorry because I'm late, I've posted a comment in the issue about the approach, PTAL and share your thoughts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use CurrentReplicas as a minimum for fallback replicas
3 participants